class AddFulltextIndexes < ActiveRecord::Migration
  def self.up
    create_table :fulltext_indices, :options => 'engine=MyISAM' do |t|
      t.column :indexable_type, :string, :limit => 60, :null => false
      t.column :indexable_id, :integer, :references => nil
      t.column :tokens, :text
    end
    execute "ALTER TABLE fulltext_indices ADD FULLTEXT KEY `tokens` (`tokens`)"
    execute "ALTER TABLE fulltext_indices ADD KEY `indexable_type` (`indexable_type`,`indexable_id`)"
  end

  def self.down
    drop_table :fulltext_indices
  end
end